/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package server; 

import server.managerServer.Listener;

/**
 * The starting point of the server application.
 * Just creating the storage collection and the listening servers.
 */
public class Server {
    private Listener adminServer;
    private UdpVoteServer voteServer;
    private VoteListener voteListener;

    public Server(int port) {
        PollList polls = new PollList();
        this.adminServer = new Listener(port, polls);
        this.voteListener = new VoteListener(polls);
        this.voteServer = new UdpVoteServer(port, voteListener);
    }

    public void startServer() {
        adminServer.start();
        voteListener.start();
        voteServer.start();
    }
    
    //create a ManagerServer and aVote Server.
    public static void main(String args[]) {
 
        if (args.length != 1) {
            System.out.println("usage: java <programName> <port>");
            System.exit(1);
        }

        int port = (new Integer(args[0])).intValue();

        new Server(port).startServer();

    }
}
